package com.jfinal.ext.ueditor.result;

import org.jetbrains.annotations.NotNull;

/**
 * @author Timor
 * @version 1.0
 * @date 2023/01/04 16:00:33
 */
public class RetResult {
    public static final String STATE_FAILURE = "FAILURE";
    public static final String STATE_SUCCESS = "SUCCESS";

    public final String state;
    public final String message;
    public final long timestamp;

    RetResult(boolean success) {
        this.state = success ? STATE_SUCCESS : STATE_FAILURE;
        this.message = null;
        this.timestamp = System.currentTimeMillis();
    }

    RetResult(@NotNull String errorMessage) {
        this.state = STATE_FAILURE;
        this.message = errorMessage;
        this.timestamp = System.currentTimeMillis();
    }


    public String getState(){
        return state;
    }

    public long getTimestamp(){
        return timestamp;
    }

    public String getMessage(){
        return message;
    }

}
